/*
 * Created by: Peter Weissbrod
 * Created: Saturday, November 03, 2007
 */
using System;
using Castle.ActiveRecord;
using Utils;

namespace EntityLayer.Entities
{
    /// <summary>
    /// this is a derived class form salesItem, it is stored in the same table
    /// its type can be inferred from the discriminator
    /// http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html 
    /// </summary>
    [ActiveRecord(DiscriminatorValue = "Book")]
    public class Book : SalesItem
    {
        #region members
        private string author = Nulls.String;
        private string isbn = Nulls.String;
        private int numPages = 0;
        #endregion

        #region properties
        [Property]
        public string Isbn
        {
            get { return isbn; }
            set { isbn = value; }
        }
        [Property]
        public int NumPages
        {
            get { return numPages; }
            set { numPages = value; }
        }
        [Property]
        public string Author
        {
            get { return author; }
            set { author = value; }
        }
        #endregion

        #region methods
        public Book(string name, User user, decimal price, DateTime postDate, int year, string isbn, int numPages,
                    string author) : base(name, user, price, postDate, year)
        {
            this.isbn = isbn;
            this.numPages = numPages;
            this.author = author;
        }
        public Book()
        {
        }
        public new static Book[] FindAll()
        {
            return FindAll(typeof (Book)) as Book[];
        }
        #endregion
    }
}